//
//  AirTicketSearchRequest.m
//  EasyToo
//
//  Created by zhengzhe on 13-8-25.
//
//

#import "AirTicketSearchRequest.h"

@implementation AirTicketSearchRequest

- (id)initWithFromCity:(NSString *)fromCity toCity:(NSString *)toCity flyTime:(NSString *)flyTime Delegate:(id<ServerCommunicationDelegate>)delegate
{
    self = [super init];
    if (self) {
        self.toCity = toCity;
        self.fromCity = fromCity;
        self.flyTime = flyTime;
        self.delegate = delegate;
        self.requestName = @"AirTicketSearchRequest";
        
        NSArray *array = [self.flyTime componentsSeparatedByString:@"/"];
        NSString *strtime = [NSString stringWithFormat:@"%@-%@-%@ 00:00:00", [array objectAtIndex:0],
                             [array objectAtIndex:1], [array objectAtIndex:2]];

        [self.bodyJsonDict setObject:self.fromCity forKey:@"org"];
        [self.bodyJsonDict setObject:self.toCity forKey:@"dst"];
        [self.bodyJsonDict setObject:@"" forKey:@"airways"];
        [self.bodyJsonDict setObject:strtime forKey:@"fltd"];
        
        [self.headerJsonDict setObject:@"015001" forKey:@"TranCode"];
        [self.headerJsonDict setObject:@"20" forKey:@"TxRecordNum"];
        [self buildJsonRequest];
    }
    return self;
}

- (void)dealloc
{
    self.toCity = nil;
    self.fromCity = nil;
    self.flyTime = nil;
    [super dealloc];
}
@end
